package com.hmkj.web.controller.pay;

import com.hmkj.common.entity.ResultEntity;
import com.hmkj.core.constant.CacheID;
import com.hmkj.core.model.pay.PayResult;
import com.hmkj.core.service.cache.RedisService;
import com.hmkj.web.controller.GenericController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 查询支付结果
 *
 * @author Vector
 * @create 2017-12-25 16:47
 */

@Api(description = "查询支付结果")
@Slf4j
@RestController
@RequestMapping(GenericController.BASE_API_URL + "/result")
public class PayResultController extends GenericController {

    @Resource
    private RedisService redisService;


    @ApiOperation(value = "查询支付结果", notes = "查询支付结果")
    @ResponseBody
    @RequestMapping(value = "getResult", method = RequestMethod.POST)
    public ResultEntity getResult(@ApiParam("业务标识") @RequestParam String hmTk) {
        PayResult result = redisService.get(CacheID.PAY_RESULT + hmTk, PayResult.class);
        return ok(result == null ? null : result);
    }
}

